package com.chuanc.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.chuanc.R;
import com.chuanc.adapter.SongSheetAdapter;
import com.chuanc.adapter.SongSheetItem;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Angel on 2017/10/18.
 */

public class MusicFragment extends AttachFragment {
    private RecyclerView playList;
    private List playListItems=new ArrayList();

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_music,container,false);
        initPlaylistView();
        playList= (RecyclerView) view.findViewById(R.id.recommend_playlist_recyclerview);
        GridLayoutManager gridLayoutManager=new GridLayoutManager(mContext,3);
        playList.setLayoutManager(gridLayoutManager);
        SongSheetAdapter songSheetAdapter=new SongSheetAdapter(playListItems);
        playList.setAdapter(songSheetAdapter);
        return view;
    }

    public void initPlaylistView(){
        int imgIds[]={R.drawable.palylist_first,R.drawable.palylist_second,
                    R.drawable.palylist_third,R.drawable.playlist_fourth,
                    R.drawable.palylist_fifth,R.drawable.playlist_sixth};
        String playNames[]={"秋乏","[醒来,读书]","泰妍美","金泰妍","氛围电子","沉醉于光影与梦呓的交织"};
        String playCount[]={"157","","128","664","300","209","389"};
        for(int i=0;i<imgIds.length;i++){
            setInfo(imgIds[i],playNames[i],playCount[i]);
        }
    }

    private void setInfo(int img, String name, String count) {
        SongSheetItem  songSheetItem=new SongSheetItem();
        songSheetItem.setAvatar(img);
        songSheetItem.setTitle(name);
        songSheetItem.setListenCount(count);
        playListItems.add(songSheetItem);
    }


}
